home *** CD-ROM | disk | FTP | other *** search
/ 1000 Apple LAN Literacy / 1000 Apple LAN Literacy.iso / Apple LAN Literacy / Literacy Segments Part 1 / Literacy Segments Part 1 / stack.txt < prev   
Text File  |  1989-08-22  |  27KB  |  897 lines

  1. -- stack: in
  2. -- format: 8 (HyperCard 1)
  3. -- flags: 0x1000 (none)
  4. -- protect password hash: 0
  5. -- maximum user level: 5 (scripting)
  6. -- window: Rect(x1=0, y1=0, x2=0, y2=0)
  7. -- screen: Rect(x1=0, y1=0, x2=0, y2=0)
  8. -- card dimensions: w=0 h=0
  9. -- scroll: x=0 y=0
  10. -- background count: 56
  11. -- first background id: 2631
  12. -- card count: 174
  13. -- first card id: 28227
  14. -- list block id: 54520
  15. -- print block id: 3382
  16. -- font table block id: 0
  17. -- style table block id: 0
  18. -- free block count: 0
  19. -- free size: 0 bytes
  20. -- total size: 640704 bytes
  21. -- stack block size: 25600 bytes
  22. -- created by hypercard version: 0x01228000
  23. -- compacted by hypercard version: 0x01228000
  24. -- modified by hypercard version: 0x01228000
  25. -- opened by hypercard version: 0x01228000
  26. -- patterns[0]: 0x0000000000000000
  27. -- patterns[1]: 0x8000000008000000
  28. -- patterns[2]: 0x8800220088002200
  29. -- patterns[3]: 0x8888222288882222
  30. -- patterns[4]: 0x88AA22AA88AA22AA
  31. -- patterns[5]: 0xCCAA33AACCAA33AA
  32. -- patterns[6]: 0xEEAABBAAEEAABBAA
  33. -- patterns[7]: 0xEEBBBBEEEEBBBBEE
  34. -- patterns[8]: 0xFFBBFFEEFFBBFFEE
  35. -- patterns[9]: 0xFFBBFFFFFFBBFFFF
  36. -- patterns[10]: 0x8010022001084004
  37. -- patterns[11]: 0xFFFFFFFFFFFFFFFF
  38. -- patterns[12]: 0x8822882288228822
  39. -- patterns[13]: 0x1122448811224488
  40. -- patterns[14]: 0xC4800C6843023026
  41. -- patterns[15]: 0xB130031BD8C00C8D
  42. -- patterns[16]: 0xAA00AA00AA00AA00
  43. -- patterns[17]: 0x8822552288225522
  44. -- patterns[18]: 0x8855225588552255
  45. -- patterns[19]: 0x77DD77DD77DD77DD
  46. -- patterns[20]: 0x8000000000000000
  47. -- patterns[21]: 0xAA55AA55AA55AA55
  48. -- patterns[22]: 0x038448300C020101
  49. -- patterns[23]: 0x8244394482010101
  50. -- patterns[24]: 0x8814224188412214
  51. -- patterns[25]: 0x8080413E080814E3
  52. -- patterns[26]: 0x22048C7422179810
  53. -- patterns[27]: 0xBE808808EB088880
  54. -- patterns[28]: 0x25C8328964244C92
  55. -- patterns[29]: 0xA29C41BE2AC914EB
  56. -- patterns[30]: 0x40A00000040A0000
  57. -- patterns[31]: 0x8040200002040800
  58. -- patterns[32]: 0xAA00800088008000
  59. -- patterns[33]: 0xFF80808080808080
  60. -- patterns[34]: 0x081C22C180010204
  61. -- patterns[35]: 0xFF808080FF080808
  62. -- patterns[36]: 0xF87422478F172271
  63. -- patterns[37]: 0xBF00BFBFB0B0B0B0
  64. -- patterns[38]: 0xFF7FBE5DA2418000
  65. -- patterns[39]: 0xFAF5FAF5A050A050
  66. -- checksum: 0x0
  67. ----- HyperTalk script -----
  68. ---------------------------------------------------------------------
  69. --                    ‚ÄúNetwork & Communications‚Äù
  70. --                   ‚ÄúApple LAN Literacy Course‚Äù
  71. --                  ¬© 1989 Apple Computer, Inc. &
  72. --                     ¬© 1989 Courseware, Inc. &
  73. --                        ¬© 1989 HyperPro, Inc.
  74. --
  75. --                          Version 1.0f5
  76. ----------------------------------------------------------------------
  77. -- Stack: Literacy Segments Part 1
  78. --
  79. -- HANDLERS: openstack,findSetUp,openBackground,Lesson,InstantReference,
  80. --           goItem,beenHereFlag,SSpopUp,doSS,checkBookmark,
  81. --           askBookmark,Help,MainMenu,SSQuit,doMenu,Map,Scrapbook,
  82. --           Index,Glossary,Note,BookMark,SnapShot,saveMyPlace,
  83. --           saveIdentifier,goBackWhere,popBack,popWhere,Search,
  84. --           returnKey,enterKey,searchForIt,SwitchStack
  85. -- FUNCTIONS: whereAmI,validField
  86. -- RESOURCES:
  87. -- ICON: Student Services,GrayPrev,Help,Prev Card,Lg #2,Lg #3,
  88. --       Lg #1 Outline,Lg #2 Outline,Lg #3 Outline,Lg #1,#1,#2,
  89. --       #1 Outline,#2 Outline,GrayNext,Next Card,Grey Up Arrow,
  90. --       Up Arrow,Modem,Telephone,Computer w/backdrop,Satelite Dish,
  91. --       Telephone Lines,Computer Cable,String,Tin Cans,Cable,
  92. --       Computer,Printer,To Menus,Lg #4,Lg #4 Outline,#3,#4,#5,
  93. --       #3 Outline,#4 Outline,#5 Outline
  94. -- XFCN: kPopUp
  95. -- vers:
  96. -- DITL: Answer
  97. -- FONT: Garamond
  98. --
  99. ----------------------------------------------------------------------
  100. --
  101. -- By Apple Computer, Inc., Courseware, Inc. & HyperPro, Inc.
  102. --
  103. ----------------------------------------------------------------------
  104.  
  105. on openstack
  106.   global setupOk
  107.  
  108.   get the version
  109.   if it < 1.2 then
  110.     answer "This stack requires HyperCard v1.2.2 or later."
  111.     go back
  112.     exit to HyperCard
  113.   end if
  114.  
  115.   if setupOk is empty then findSetup -- otherwise it's true, continue
  116.  
  117.   global gSystemFile,useSS,mapTracker
  118.   if useSS then
  119.     open file gSystemFile
  120.     read from file gSystemFile for 16384
  121.     put line 1 to 3 of it into theContents
  122.     close file gSystemFile
  123.     put mapTracker into line 4 of theContents --*!*
  124.     open file gSystemfile
  125.     write theContents to file gSystemFile
  126.     close file gSystemFile
  127.   end if
  128.   hide menubar
  129.   hide msg
  130. end openStack
  131.  
  132. on findSetUp
  133.  
  134.   set lockmessages to true
  135.   set cursor to watch
  136.   go stack "Literacy Course"
  137.   if the result is "cancel" then
  138.     answer "Unable to continue.  ‚ÄúLiteracy Course‚Äù not found."
  139.     domenu Quit Hypercard
  140.     exit to Hypercard -- exit calling handlers
  141.   else -- found course setup card
  142.     set lockmessages to false
  143.     send openstack to this stack -- the setup stack
  144.     exit to HyperCard
  145.   end if
  146. end findSetUp
  147.  
  148. on openBackground
  149.   global mapTracker
  150.   get char 1 to 5 of the short name of this bg
  151.   if it is not in mapTracker then
  152.     put it & "," after mapTracker
  153.   end if
  154.   pass openBackground
  155. end openBackground
  156.  
  157. on Lesson
  158.   lock screen
  159.   set cursor to watch
  160.   put char 1 to 5 of the short name of this bg into segNum
  161.   go "Literacy Main Menu"
  162.   get script of bg btn "Card Key"
  163.   put offset(segNum,it) into temp
  164.   put line (number of lines in char 1 to temp of it) of it into theCard
  165.   delete char 1 to 6 of theCard
  166.   go cd theCard
  167.   unlock screen with visual zoom open
  168. end Lesson
  169.  
  170. on InstantReference segNum
  171.   lock screen
  172.   get the clickloc
  173.   put item 1 of it into x
  174.   put item 2 of it into y
  175.  
  176.   put left of the target + width of the target - x into x1
  177.   put y - top of the target into y1
  178.  
  179.   put x - item 1 of the loc of the target into x2
  180.   put y - item 2 of the loc of the target into y2
  181.  
  182.   subtract left of the target from x
  183.   subtract top of the target from y
  184.  
  185.   if SQRT(x2*x2 + y2*y2) > 27 then exit InstantReference
  186.  
  187.   if x1 < y1
  188.   then
  189.   if x < y
  190.   then
  191.   go cd 1 of bg (segNum && "Practice")
  192. else
  193.   go cd 1 of bg (segNum && "Example")
  194. end if
  195. else
  196.   if x < y
  197.   then
  198.   go cd 1 of bg (segNum && "Information")
  199. else
  200.   go cd 1 of bg (segNum && "Content")
  201. end if
  202. end if
  203. unlock screen
  204. end InstantReference
  205.  
  206. on goItem
  207.   put last char of the short name of the target into temp
  208.   put "#" & temp into btnNumb -- btn names are #1, #2, etc
  209.   put "422" & temp into iconNumb -- or "424" for large numbers
  210.   set the icon of btn btnNumb to iconNumb
  211.   go cd temp + the number of this cd
  212. end goItem
  213.  
  214. on beenHereFlag itemNum,lineNum
  215.   global btnStatus
  216.  
  217.   -- if line (other than first) of var is empty, then placement of data
  218.   -- in particular "item" doesn't work due to HyperCard 1.2.2 bug. So if
  219.   -- line empty, string "dummy" goes in, data placed, & string pulled.
  220.  
  221.   if line lineNum of btnStatus is empty
  222.   then put "dummy" into line lineNum of btnStatus
  223.   put "true" into item itemNum of line lineNum of btnStatus
  224.   if item 1 of line lineNum of btnStatus = "dummy"
  225.   then put empty into item 1 of line lineNum of btnStatus
  226. end beenHereFlag
  227.  
  228. -----------------Here are the StudentServices scripts ------------------
  229. -- version 1.0f4
  230.  
  231. on SSpopUp
  232.   global useSS,course
  233.  
  234.   set hilite of the target to true
  235.   get kPopUp("init",999) -- creates menu in memory
  236.  
  237.   -- "(" is meta character for disable item.
  238.   if useSS then
  239.     get the short name of this stack
  240.     if (it contains "scrapbooK") or (it contains "snapshot") then
  241.       put "MainMenu;" & "(" & "BookMark‚Ķ;" & "(" & "Note‚Ķ;" & "(" & "SnapShot‚Ķ;Index;Scrapbook;" & "Search‚Ķ;Map;Glossary;Quit‚Ķ" into choice
  242.     else
  243.       put "MainMenu;BookMark‚Ķ;Note‚Ķ;SnapShot‚Ķ;Index;Scrapbook;" & "Search‚Ķ;Map;Glossary;Quit‚Ķ" into choice
  244.     end if
  245.   else
  246.     put "MainMenu;" & "(" & "BookMark‚Ķ;" & "(" & "Note‚Ķ;" & "(" & "SnapShot‚Ķ;" & "(" & "Index;" & "(" & "Scrapbook;" & "Search‚Ķ;Map;Glossary;Quit‚Ķ" into choice
  247.   end if
  248.  
  249.   if not course then -- needed for scrapbook & snaps scripts only
  250.     put "(" & "MainMenu;" & "(" & "BookMark‚Ķ;" & "(" & "Note‚Ķ;" & "(" & "SnapShot‚Ķ;Index;Scrapbook;" & "Search‚Ķ;" & "(" & "Map;Glossary;Quit‚Ķ" into choice
  251.   end if
  252.  
  253.   get kPopUp("append",999,choice) -- 999 is reference #
  254.  
  255.   -- popup menu doesn't show yet
  256.   get kPopUp("pop",999,1,bottom of the target,left of the target + 1)
  257.   -- pop returns ID number of menu, number of item selected
  258.   set cursor to watch
  259.  
  260.   put kPopUp("GetItem",item 1 of it,item 2 of it) into command
  261.   -- returns text of item
  262.  
  263.   get kPopUp("toss",999) -- remove menu from memory
  264.  
  265.   set hilite of the target to false
  266.   if last char of command is "‚Ķ" then delete last char of command
  267.   -- Don't use "quit" -- potential conflicts with home scripts
  268.   if command = "quit" then put SSQuit into command
  269.   checkBookmark command
  270.   if command ‚↠"no such menu" then
  271.     do command
  272.   end if
  273. end SSpopUp
  274.  
  275. on doSS
  276.   global scrapFile
  277.  
  278.   if the short name of this stack contains "scrapbook" then
  279.     send doSS to bg 1 -- script is there, shortcut heirarchy
  280.     exit to HyperCard
  281.   end if
  282.   lock screen
  283.   push card
  284.   set lockmessages to true
  285.   set cursor to watch
  286.   go stack scrapFile
  287.   if the result is "cancel" then popBack
  288.   -- call with Literacy, ANP, or Administration from courses *!*
  289.   -- call with "scrapbook" from snapshots or scrapbook *!*
  290.   put SSDialog("Literacy") into command --*!*
  291.   pop card
  292.   unlock screen
  293.   set lockmessages to false
  294.   checkBookmark command
  295.   -- Don't use "quit" -- potential conflicts with home scripts
  296.   if command = "quit" then put SSQuit into command
  297.   if command = "Cancel" then exit doSS
  298.   else do command
  299. end doSS
  300.  
  301. on checkBookmark command
  302.   global useSS
  303.  
  304.   if whereAmI() then exit checkBookMark
  305.   if not useSS then exit checkBookMark
  306.   if command = "MainMenu" or command = "Index" or command = "Scrapbook" or command = "Map" or command = "Glossary" then askBookmark command
  307. end checkBookmark
  308.  
  309. on askBookmark command
  310.   global bookmarkPref
  311.  
  312.   if bookmarkPref then
  313.     answer "Create Bookmark before going to" && command & "?" with "Cancel" or "Just go" or "Bookmark"
  314.   else
  315.     answer "Create Bookmark before going to" && command & "?" with "Cancel" or "Bookmark" or "Just go"
  316.   end if
  317.   if it is "Cancel" then exit to HyperCard
  318.   if it is "just go" then put false into bookmarkPref
  319.   if it is "Bookmark" then
  320.     put true into bookmarkPref
  321.     bookmark
  322.   end if
  323. end askBookmark
  324.  
  325. on Help
  326.   global course
  327.  
  328.   if not course then
  329.     answer "Help is not available without the course."
  330.     exit help
  331.   end if
  332.   lock screen
  333.   saveMyPlace
  334.   set cursor to watch
  335.   go stack "N&C Help"
  336.   if the result is "cancel" then goBackWhere -- exits
  337.   hide cd pict
  338.   unlock screen with visual dissolve
  339.   wait 30
  340.   show cd pict
  341. end Help
  342.  
  343. on MainMenu
  344.   lock screen
  345.   set LockMessages to true
  346.   set cursor to watch
  347.   go stack "Literacy Main Menu" -- or Literacy or Administration *!*
  348.   if the result is "cancel" then exit to Hypercard
  349.  
  350.   -- Literacy doesn't do this.
  351.   if the short name of this stack is "ANP Main Menu" then
  352.     repeat with k = the number of cds down to 1
  353.       go cd k
  354.       opencard
  355.     end repeat
  356.   end if
  357.  
  358.   set lockMessages to false
  359.   unlock screen with visual dissolve
  360. end MainMenu
  361.  
  362. on SSQuit
  363.   global gSystemFile,useSS,mapTracker,menuHilites,course
  364.   global bookmarkPref,wherewecamefrom,OKtoQuit,scrapFile
  365.  
  366.   put whereAmI() into fromScrapbook --*!* use false in peripherals
  367.   if not useSS then put true into fromScrapbook -- no bookmarks
  368.   if fromScrapbook then
  369.     answer "Do you want to quit the course?" with "Cancel" or "Yes, quit"
  370.     if it is "Cancel" then
  371.       exit to Hypercard
  372.     end if
  373.   else
  374.     if bookmarkPref then
  375.       answer "Create Bookmark & quit this course?" with "Cancel" or "Just quit" or "OK"
  376.     else
  377.       answer "Create Bookmark & quit this course?" with "Cancel" or "OK" or "Just quit"
  378.     end if
  379.     if it is "Cancel" then exit to hypercard
  380.     if it is "OK" then bookmark
  381.   end if
  382.   if not fromscrapbook then saveMyPlace
  383.   if useSS and course then
  384.     open file gSystemFile
  385.     read from file gSystemFile for 16384
  386.     put line 1 to 2 of it into theContents
  387.     close file gSystemFile
  388.     put wherewecamefrom into line 3 of theContents
  389.     put mapTracker into line 4 of theContents
  390.     open file gSystemfile
  391.     write theContents to file gSystemFile
  392.     close file gSystemFile
  393.  
  394.     lock screen
  395.     go stack scrapFile
  396.     put theContents into cd fld "hidden name"
  397.   end if
  398.   put true into OKtoQuit
  399.   domenu "Quit Hypercard"
  400.   exit to hypercard
  401. end SSquit
  402.  
  403. on doMenu var
  404.   global OKtoQuit
  405.  
  406.   if OKtoQuit is empty then put false into OKtoQuit
  407.   if var = "Find..." then search --*!* not in peripherals
  408.   else if var = "Quit HyperCard" and OKtoQuit is false then ssQuit
  409.   else if var = "Quit HyperCard" and OKtoQuit then pass doMenu
  410.   else pass doMenu
  411. end doMenu
  412.  
  413. on Map
  414.   global gSystemFile
  415.  
  416.   put whereAmI() into fromScrapbook
  417.   if gSystemFile contains "ANP" then put true into ANPCourse
  418.   else put false into ANPCourse
  419.   saveMyPlace
  420.   lock screen
  421.  
  422.   if ANPCourse then
  423.     put char 1 to 5 of short name of this stack into temp
  424.   else
  425.     put char 1 to 5 of the short name of this bg into temp
  426.   end if
  427.  
  428.   set cursor to watch
  429.   go stack "Literacy Map" -- or Literacy or Administration *!*
  430.   if the result is "cancel" then goBackWhere -- exits
  431.  
  432.   if fromScrapbook then
  433.     unlock screen with visual dissolve
  434.     exit map
  435.   end if
  436.  
  437.   if not ANPCourse then -- Literacy map
  438.     set icon of bg btn temp to 1201
  439.     put temp into num
  440.     put "0" into last char of temp   -- calc number for current lesson
  441.     put script of bg btn "lesson key" into theList
  442.     -- "Lesson Key" holds # of first cd where lesson appears
  443.     put offset(temp,theList) into theLine
  444.     put word 2 of line (number of lines in char 1 to theLine of theList) of theList into theCard
  445.     go cd theCard
  446.     show cd fld "instruction"
  447.     put num into hiliter
  448.   else -- ANP map
  449.     click at the loc of bg btn temp
  450.     put "Go" && temp into hiliter
  451.   end if
  452.  
  453.   unlock screen with visual dissolve
  454.   repeat 3
  455.     set the hilite of btn hiliter to true
  456.     wait 20
  457.     set the hilite of btn hiliter to false
  458.     wait 20
  459.   end repeat
  460. end Map
  461.  
  462. on Scrapbook
  463.   global scrapFile,whereWeCameFrom
  464.  
  465.   put whereAmI() into fromScrapbook
  466.   saveMyPlace
  467.   set cursor to watch
  468.   lock screen
  469.   go cd 1 of stack scrapFile
  470.   if the result is "cancel" then goBackWhere -- exits
  471.   if fromScrapbook then delete last item of wherewecameFrom
  472.   send openbackground to this cd
  473.   unlock screen with visual dissolve
  474. end Scrapbook
  475.  
  476. on Index
  477.   global scrapFile,whereWeCameFrom
  478.  
  479.   put whereAmI() into fromScrapbook
  480.   saveMyPlace
  481.   lock screen
  482.   set cursor to watch
  483.   go cd "Index" of stack scrapFile
  484.   if the result is "cancel" then goBackWhere -- exits
  485.   if fromScrapbook then delete last item of whereWeCameFrom
  486.   send openbackground to this cd
  487.   unlock screen with visual dissolve
  488. end Index
  489.  
  490. on Glossary
  491.   global scrapFile,whereWeCameFrom
  492.  
  493.   put whereAmI() into fromScrapbook
  494.   saveMyPlace
  495.   lock screen
  496.   set cursor to watch
  497.   go cd "Glossary" of stack scrapFile
  498.   if the result is "cancel" then goBackWhere -- exits
  499.   if fromScrapbook then delete last item of whereWeCameFrom
  500.   send openbackground to this cd
  501.   unlock screen with visual dissolve
  502. end Glossary
  503.  
  504. -- note isn't available from Student Scrapbook
  505. on Note
  506.   global scrapFile
  507.  
  508.   saveIdentifier
  509.   put false into madeNote
  510.   push cd
  511.   set cursor to watch
  512.   lock screen
  513.   set lockMessages to true
  514.   go cd "index" of stack scrapFile
  515.   if the result is "cancel" then popBack -- exits
  516.   put makeNote() into myResult
  517.   if myResult is "successful" then put true into madeNote
  518.   pop cd
  519.   set lockmessages to false
  520.   if madeNote then unlock screen with iris open to black
  521.   else unlock screen
  522.   if myResult is "SS" then doSS
  523. end Note
  524.  
  525. -- Bookmark isn't available from Student Scrapbook.
  526. on BookMark
  527.   global scrapFile
  528.  
  529.   saveIdentifier
  530.   saveMyPlace
  531.   put false into madeBookMark
  532.   push cd
  533.   set cursor to watch
  534.   lock screen
  535.   set lockMessages to true
  536.   go cd "index" of stack scrapFile
  537.   if the result is "cancel" then popWhere -- exits
  538.   put makeBookMark() into myResult
  539.   if myResult is "successful" then put true into madeBookMark
  540.   pop cd
  541.   set lockmessages to false
  542.   if madeBookMark then unlock screen with iris open to black
  543.   else unlock screen
  544.   if myResult is "SS" then doSS
  545. end bookMark
  546.  
  547. -- Snapshot isn't available from the Student Scrapbook.
  548. on SnapShot
  549.   global scrapFile
  550.  
  551.   saveMyPlace
  552.   saveIdentifier
  553.   put false into madeSnapShot
  554.   push cd
  555.   set cursor to watch
  556.   lock screen
  557.   unlock screen -- for refresh, since we're taking a picture of it
  558.   lock screen
  559.   set lockMessages to true
  560.   go cd "index" of stack scrapFile
  561.   if the result is "cancel" then popWhere -- exits
  562.   put makeSnapShot() into myResult
  563.   if myResult is "successful" then put true into madeSnapShot
  564.   pop cd
  565.   set lockmessages to false
  566.   if madeSnapShot then unlock screen with iris open to black
  567.   else unlock screen
  568.   if myResult is "SS" then doSS
  569. end SnapShot
  570.  
  571. function whereAmI
  572. get the short name of this stack
  573. if it contains "scrapbook" or it contains "snapshot" then
  574.   return true
  575. else
  576.   return false
  577. end if
  578. end whereAmI
  579.  
  580. on saveMyPlace
  581.   global whereWeCameFrom
  582.  
  583.   put the id of this cd && "of stack" && quote & the short name of this stack & quote into thisPlace
  584.   if not (last item of whereWeCameFrom = thisPlace) then
  585.     put thisPlace into item (number of items in whereWeCameFrom) + 1 of whereWeCameFrom
  586.   end if
  587. end saveMyPlace
  588.  
  589. on saveIdentifier
  590.   global identifier
  591.  
  592.   put the short name of this cd into identifier
  593. end saveIdentifier
  594.  
  595. on goBackWhere
  596.   global wherewecamefrom
  597.  
  598.   set cursor to watch
  599.   go last item of whereWeCameFrom
  600.   delete last item of whereWeCameFrom
  601.   set lockMessages to false
  602.   exit to Hypercard
  603. end goBackWhere
  604.  
  605. on popBack
  606.   pop card
  607.   set lockMessages to false
  608.   exit to hypercard
  609. end popBack
  610.  
  611. on popWhere
  612.   global whereWeCameFrom
  613.  
  614.   pop card
  615.   delete last item of whereWeCameFrom
  616.   set lockMessages to false
  617.   exit to Hypercard
  618. end popWhere
  619.  
  620. -----------------  Search script handlers‚Ķ
  621. --
  622. -- Search script hunts for string through multiple stacks.
  623. -- Each stack must have the handlers in it for this to work.
  624. -- Modified from TIE search script which was written by Garth
  625. -- Catterall and Ken Laws.  Leslie Grimm
  626.  
  627. on Search
  628.   global gfindWhat,gfindHow,gFindWhere,gWhichStack,gFirstStack, gFindFlag,gFirstCard,gFindCount,gFirstChunk,gStartCard,gLastCard, gNumStacks,gNextStack
  629.   global scrapFile
  630.  
  631.   push card
  632.   lock screen
  633.   set lockmessages to true
  634.   set cursor to watch
  635.   put whereAmI() into fromScrapbook
  636.   go stack scrapFile
  637.   if the result is "cancel" then
  638.     pop card into trash -- clean up stack
  639.     exit to Hypercard
  640.   end if
  641.   -- get gfindWhat,gfindWhere,gfindHow & gNextStack
  642.   put searchDialog(fromScrapbook) into myResult
  643.  
  644.   if myResult is "SS" then
  645.     pop card
  646.     set lockmessages to false
  647.     unlock screen
  648.     doSS
  649.     exit search
  650.   end if
  651.  
  652.   if myResult is "Cancel" then
  653.     pop card
  654.     set lockmessages to false
  655.     unlock screen
  656.     exit search
  657.   end if
  658.  
  659.   if myResult is "Bookmark" then
  660.     pop card
  661.     set lockmessages to false
  662.     bookmark
  663.     push card
  664.     -- then continue search
  665.   end if
  666.  
  667.   put empty into gFirstChunk -- reset variables
  668.   put empty into gFirstCard
  669.   put the visible of the msg into visiMsg
  670.   put empty into msg -- so return/enter will work.  See below.
  671.   set the visible of the msg to visimsg
  672.   put 0 into gFindCount
  673.   put 1 into gWhichStack
  674.   put true into gFindFlag -- search is valid
  675.  
  676.   pop card
  677.   push card -- so we can come back later
  678.   unlock screen -- screen refresh
  679.   lock screen
  680.   put the number of this cd into gStartCard
  681.   if not fromScrapbook then saveMyPlace -- to get back from glossary
  682.   put the short name of this stack into gFirstStack
  683.  
  684.   -- initialize index for searching through multiple stacks
  685.   put the number of items in gNextStack into gNumstacks
  686.   put false into inList
  687.   repeat with i = 1 to gNumStacks
  688.     if (item i of gNextStack contains gFirstStack) then
  689.       put i into gWhichStack
  690.       put true into inList
  691.       exit repeat
  692.     end if
  693.   end repeat
  694.   if not inList then
  695.     put 1 into gWhichStack
  696.     put item 1 of gNextStack into gFirstStack
  697.     set lockmessages to true
  698.     go stack gFirstStack
  699.     put 1 into gStartCard
  700.   end if
  701.  
  702.   searchForIt
  703.  
  704. end Search
  705.  
  706. on returnKey
  707.   global gFindWhat,gFindFlag,gNextStack
  708.  
  709.   if (gFindWhat ‚↠empty) and (gFindFlag = true) and (the msg is empty) then
  710.     searchForIt
  711.   else
  712.     -- ** put empty into gNextStack -- clear possibly big variable
  713.     pass returnKey
  714.   end if
  715. end returnKey
  716.  
  717. on enterKey
  718.   global gFindWhat,gFindFlag,gNextStack
  719.  
  720.   if (gFindWhat ‚↠empty) and (gFindFlag = true) and (the msg is empty) then
  721.     searchForIt
  722.   else
  723.     --** put empty into gNextStack -- clear possibly big variable
  724.     pass enterKey
  725.   end if
  726. end enterKey
  727.  
  728. on searchForIt
  729.   global gFindWhat,gFindHow,gFindWhere,gWhichStack,gNumStacks, gStartCard,gFindFlag,gFirstCard,gFindCount,gFirstChunk,gLastCard
  730.  
  731.   set cursor to busy
  732.   --** lock screen
  733.   put the number of this cd into gLastCard
  734.  
  735.   set lockmessages to true
  736.   repeat
  737.     set cursor to busy
  738.     if gFindHow = "Exact String" then find string gFindWhat
  739.     else if gFindHow = "First Characters" then find gFindWhat
  740.     else if gFindHow = "Whole Word(s)" then find whole gFindWhat
  741.  
  742.     put the FoundChunk into holder -- eg char 1 to 6 of cd fld 4
  743.     put the short name of the FoundField into checker
  744.  
  745.     if holder is empty then  -- not found anywhere in the stack
  746.       -- if we were only looking in one stack, then leave
  747.       if gNumstacks = 1 then
  748.         pop card -- go back where we started
  749.         answer "Couldn‚Äôt find ‚Äú" & gFindWhat & ".‚Äù"
  750.         put false into gFindFlag
  751.         set lockmessages to false
  752.         exit searchForIt
  753.       else
  754.         SwitchStack
  755.         next repeat
  756.       end if
  757.     end if
  758.  
  759.     if gFirstChunk is empty then  -- set our references
  760.       put holder into gFirstChunk -- eg char 1 to 6 of cd fld 4
  761.       put the number of this cd into gFirstCard
  762.     else
  763.       -- is this where we started the search?
  764.       if (holder = gFirstChunk) and (the number of this card = gFirstCard) then
  765.         if gNumStacks > 1 then
  766.           SwitchStack
  767.           next repeat
  768.         end if
  769.         if gFindCount = 0 then
  770.           pop card
  771.           answer "‚Äú" & gFindWhat & "‚Äù not found."
  772.           put false into gFindFlag
  773.           put empty into gNextStack -- free the memory
  774.           set lockmessages to false
  775.           exit searchForIt
  776.         else
  777.           answer "No more occurrences of ‚Äú" & gFindWhat & "‚Äù were found."
  778.           if gStartCard ‚↠(the number of this cd) or gLastCard ‚↠(the number of this cd) then
  779.             answer "Stay here or go back to beginning card?" with "Stay" or "Go back"
  780.             if it is "go back" then pop card
  781.             else
  782.               pop cd into throwaway -- clean up our poo-poo
  783.               if the short name of this bg is "glossary" or the short name of this bg is "snapshots" then
  784.                 -- update return arrow and tabs
  785.                 send openbackground to this background
  786.               end if
  787.             end if
  788.           end if
  789.         end if
  790.         put false into gFindFlag
  791.         set lockmessages to false
  792.         exit searchForIt
  793.       end if
  794.     end if
  795.  
  796.     -- We do the check for valid fields after setting firstCard
  797.     -- so that we know where the first found item was, even though
  798.     -- it might not be visible.
  799.     if the short name of this cd is "glossary" then
  800.       if gFindWhere contains "glossary" then
  801.         send openbackground to bg "glossary" -- to mask tabs if needed
  802.         add 1 to gFindCount
  803.         send glossFind to bg "glossary"
  804.         exit searchforit
  805.       else
  806.         next repeat -- skip
  807.       end if
  808.     end if
  809.  
  810.     if the visible of the FoundField is false then next repeat
  811.     if not validField(checker) then next repeat
  812.  
  813.     add 1 to gFindCount
  814.     exit repeat
  815.   end repeat
  816. end searchForIt
  817.  
  818. -- Test whether the field in which the text was found is a valid one.
  819. function validField fieldName
  820. global gfindWhere
  821.  
  822. -- do a quick repeat to ensure it's a field we want to find in
  823. -- Note that this is slower, but more definitive than a "contains"
  824. -- This defines the fields that we don't want to find in...
  825.  
  826. if the short name of this stack contains "Scrapbook" then
  827.   put "Title,Lines,List holder,MyName,Identifier,Date/Time," & "instruction,comment,the word,definition" into badFields
  828.   -- don't search notes if this is a glossary-only search
  829.   if not (gfindWhere contains "scrapbook") then
  830.     put ",list,Note" after badFields -- skip note cards
  831.   end if
  832. else
  833.   -- it's a course or snapshot
  834.   put "StackName,Instruction,instruction2," & "Indicator,Title" into badFields
  835. end if
  836.  
  837. repeat with i = 1 to number of items in badFields
  838.   if fieldName = item i of badFields then
  839.     return false
  840.   end if
  841. end repeat
  842.  
  843. return true
  844. end validField
  845.  
  846. on SwitchStack
  847.   global gFindWhat,gFindHow,gFindWhere,gWhichStack,gFirstStack, gStartCard,gFindFlag,gFirstCard,gFindCount,gFirstChunk,gNextStack
  848.  
  849.   set cursor to busy
  850.  
  851.   if gWhichStack < (the number of items in gNextStack) then
  852.     add 1 to gWhichStack
  853.   else
  854.     put 1 into gWhichStack
  855.   end if
  856.   if (item gWhichStack of gNextStack) contains gFirstStack then
  857.     if gFindCount = 0 then
  858.       pop card -- back to start
  859.       answer "‚Äú" & gFindWhat & "‚Äù not found."
  860.       put false into gFindFlag
  861.       put empty into gNextStack -- free the memory
  862.       set lockmessages to false
  863.       exit to HyperCard
  864.     else
  865.       answer "No more occurrences of ‚Äú" & gFindWhat & "‚Äù were found."
  866.     end if
  867.     if gFindCount > 0 then
  868.       answer "Stay here or go back to beginning card?" with "Stay" or "Go back"
  869.       if it is "go back" then
  870.         set lockmessages to true
  871.         pop card -- to return from whence we came...
  872.         set lockmessages to false
  873.         unlock screen with visual iris close
  874.       else
  875.         pop card into trash -- clean up
  876.         if the short name of this bg is "glossary" or the short name of this bg is "snapshots" then
  877.           -- update return arrow and tabs
  878.           send openbackground to this background
  879.         end if
  880.       end if
  881.       put false into gFindFlag
  882.       exit to hypercard
  883.     end if
  884.   else -- go look in next stack
  885.     set lockmessages to true
  886.     set lockmessages to true
  887.     go stack (item gWhichStack of gNextStack)
  888.     set lockmessages to false
  889.     unlock screen with visual wipe left
  890.     lock screen
  891.     put empty into gFirstChunk -- resets "gone once around stack" var.
  892.   end if
  893. end SwitchStack
  894.  
  895. --------------- End of stuff to copy to all course stacks -----------
  896.  
  897.